鮭魚出生後會往下游生活,
到了產卵季節,會逆游而上,
回到最初的起點,進行產卵產卵,
C#也有像鮭魚一樣的行為,
一個參數盡方法進行加工,
加工完成後就會回家了
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CsharpDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            //宣告一隻雞
            string chicken = "一隻雞";
            Console.WriteLine("小時候 : " + chicken);
            //呼叫成長方法
            ChangAChicken(ref chicken);
            Console.WriteLine("漂泊完回家後的雞 : " + chicken);
            Console.ReadKey();
        }
        //宣告小雞長大的方法,這邊使用常數方法,不需要做return
        static void ChangAChicken(ref string newChicken)
        {
            //讓雞進化
            newChicken = "孤獨" + newChicken;
        }
    }
  }
結果:
小時候 : 一隻雞
漂泊完回家後的雞 : 孤獨一隻雞
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CsharpDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            //宣告圓半徑
            double x = 4;
            Console.WriteLine("圓半徑 : " + x);
            //宣告圓周長
            double y;
            //呼叫計算方法
            double area = GetArea(x, out y);
            Console.WriteLine("圓周長 = " + y);
            Console.WriteLine("圓面積 = " + area);
            Console.ReadKey();
        }
        //宣告方法來計算面積,要return 面積,out  圓周長
        static double GetArea(double r, out double y)
        {
            //計算圓周長
            y = 2 * r * Math.PI;
            //計算圓面積
            double s = (r * r) * Math.PI;
            return s;
        }
    }
  }
結果:
圓半徑 : 4
圓周長 = 25.1327412287183
圓面積 = 50.2654824574367